using SqlSugar;
using IM.Easy.Core.Audit;

namespace IM.Easy.Entity.Scheduled
{
    /// <summary>
    /// 调度任务扩展表
    /// </summary>
    [SugarTable("ScheduledJobExtend")]
    public class ScheduledJobExtend
    {
        /// <summary>
        /// 唯一标识
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, ColumnName = "Id")]
        public Guid Id { get; set; }

        /// <summary>
        /// 任务ID
        /// </summary>
        [SugarColumn(ColumnName = "JobId")]
        public Guid JobId { get; set; }

        /// <summary>
        /// 任务类型（远程请求，本地程序）
        /// </summary>
        [SugarColumn(ColumnName = "Type")]
        public JobType Type { get; set; }

        /// <summary>
        /// 具体类型
        /// </summary>
        [SugarColumn(ColumnName = "JobType")]
        public string? JobType { get; set; }


        /// <summary>
        /// 其他参数
        /// </summary>
        [SugarColumn(ColumnName = "Params", IsJson = true)]
        public List<ScheduleParams>? Params { get; set; } = [];

        /// <summary>
        /// 远程地址
        /// </summary>
        [SugarColumn(ColumnName = "Remote")]
        public string? Remote { get; set; }

        /// <summary>
        /// 远程调用方式
        /// </summary>
        [SugarColumn(ColumnName = "Method")]
        public string? Method { get; set; }

    }

    public class ScheduleParams
    {
        public string Key { get; set; }

        public string Value { get; set; }
    }

    public enum JobType
    {
        /// <summary>
        /// 远程请求
        /// </summary>
        Remote = 0,

        /// <summary>
        /// 本地程序
        /// </summary>
        LocalProgram = 1,
    }
}
